clear; clc;

%不同的计算机需要修改此处的地址以调用txt文件
f=load('/Users/tingting/Desktop/A_f.txt');
g=load('/Users/tingting/Desktop/A_g.txt');
h=load('/Users/tingting/Desktop/A_h.txt');
figure;
hold on;
axis([0.996,1.004,0,1e-20]);
x=0.99:0.0002:1.01;
l(1)=plot(x,f,'Linewidth',2);
l(2)=plot(x,g,'Linewidth',2);
l(3)=plot(x,h,'Linewidth',2);

legendText = legend([l(1),l(2),l(3)],'f(x)','g(x)','h(x)','FontSize', 18,'FontName','problem_A','location','northeast');

% 以下为直接用matlab生成数据的方法。
% x=0.99:0.0002:1.01;
% f=zeros(1,101);
% g=zeros(1,101);
% h=zeros(1,101);
% for i=1:101
%     f(i)=x(i)^8-8*x(i)^7+28*x(i)^6-56*x(i)^5+70*x(i)^4-56*x(i)^3+28*x(i)^2-8*x(i)+1;
%     g(i)=(((((((x(i)-8)*x(i)+28)*x(i)-56)*x(i)+70)*x(i)-56)*x(i)+28)*x(i)-8)*x(i)+1;
%     h(i)=(x(i)-1)^8;
% end
% figure;
% hold on;
% l(1)=plot(x,f,'Linewidth',2);
% l(2)=plot(x,g,'Linewidth',2);
% l(3)=plot(x,h,'Linewidth',2);
% 
% legendText = legend([l(1),l(2),l(3)],'f(x)','g(x)','h(x)','FontSize', 18,'FontName','problem_A','location','northeast');
% 